#ifndef CLIENT_H
#define CLIENT_H

#include <QObject>
#include <iostream>
#include <strings.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <stdlib.h>
#include <memory.h>
#include <arpa/inet.h>
#include <netinet/in.h>

#define PORT    11910
#define Buflen  1024
#define SERVERIP  "127.0.0.1"

using namespace std;
class client
{  
public:
    enum cmdtype
    {
        CMD_REJEST,
        CMD_LOGIN,
        CMD_SENDMESSAGE
    };

    struct data
    {
        int sender;
        int receiver;
        cmdtype cmd;
        char  buf[1024];
    };

public:
    explicit client();
    static client *inst();
    void registClient();
    int closeClient();
private:
    void handle();

private:
    int s;   //存储套接字描述符
    static client* s_inst;

};

#endif // CLIENT_H
